import 'package:casdon/common/state/common_net_status.dart';
import 'package:casdon/modules/login/domain/states/login_state.dart';

class LoginOnetapState extends LoginState {
  LoginOnetapState({
    required super.status,
    required super.version,
    super.agreed,
    super.message,
    super.errorCode,
  });

  // 可扩展的 getter
  get socialCode => null;
  get socialState => null;

  static LoginOnetapState initial() => LoginOnetapState(
    status: CommonNetStatus.idle,
    version: 1,
    agreed: false,
    message: null,
    errorCode: null,
  );

  // ✅ 私有标记对象，保证 copyWith 传 null 不覆盖原值
  static const Object _sentinel = Object();

  @override
  LoginOnetapState copyWith({
    Object? status = _sentinel,
    Object? message = _sentinel,
    Object? version = _sentinel,
    Object? agreed = _sentinel,
    Object? errorCode = _sentinel,
  }) {
    return LoginOnetapState(
      status: status == _sentinel
          ? this.status
          : status as CommonNetStatus? ?? this.status,
      message: message == _sentinel ? this.message : message as String?,
      version: version == _sentinel
          ? this.version
          : version as int? ?? this.version,
      agreed: agreed == _sentinel
          ? this.agreed
          : agreed as bool? ?? this.agreed,
      errorCode: errorCode == _sentinel ? this.errorCode : errorCode as String?,
    );
  }
}
